package com.ngkj.zmfptback.sys.bean;

import com.baomidou.mybatisplus.annotation.TableName;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.io.Serializable;
import java.util.Collection;
import java.util.List;

/**
 * @author ChenHN
 * @since 2021/12/1 creation
 **/
@TableName("sys_user")
public class UserEntity implements UserDetails, Serializable {

    private Integer id;
    private String username;
    private String password;
    private String headImage;
    private String lastLoginTime;
    private String createTime;
    private String email;
    private String isReal;
    private String nickname;
    private RealUserEntity realUser;
    private List<RoleEntity> roleEntities;

    private Collection<? extends GrantedAuthority> authorities;

    public UserEntity(){

    }

    public void setAuthorities(Collection<? extends GrantedAuthority> authorities) {
        this.authorities = authorities;
    }

    public UserEntity(Integer id, String username, String password, Collection<? extends GrantedAuthority> authorities){
        this.id = id;
        this.username = username;
        this.password = password;
        this.authorities = authorities;
    }

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public String getPassword() {
        return password;
    }

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    @Override
    public String getUsername() {
        return username;
    }

    @Override
    public boolean isAccountNonExpired() {
        return true;
    }

    @Override
    public boolean isAccountNonLocked() {
        return true;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return true;
    }

    @Override
    public boolean isEnabled() {
        return true;
    }

    public String getHeadImage() {
        return headImage;
    }

    public void setHeadImage(String headImage) {
        this.headImage = headImage;
    }

    public String getLastLoginTime() {
        return lastLoginTime;
    }

    public void setLastLoginTime(String lastLoginTime) {
        this.lastLoginTime = lastLoginTime;
    }

    public String getCreateTime() {
        return createTime;
    }

    public void setCreateTime(String createTime) {
        this.createTime = createTime;
    }

    public String getNickname() {
        return nickname;
    }

    public void setNickname(String nickname) {
        this.nickname = nickname;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public RealUserEntity getRealUser() {
        return realUser;
    }

    public void setRealUser(RealUserEntity realUser) {
        this.realUser = realUser;
    }

    public List<RoleEntity> getRoleEntities() {
        return roleEntities;
    }

    public void setRoleEntities(List<RoleEntity> roleEntities) {
        this.roleEntities = roleEntities;
    }

    public String getIsReal() {
        return isReal;
    }

    public void setIsReal(String isReal) {
        this.isReal = isReal;
    }

    @Override
    public String toString() {
        return "UserEntity{" +
                "id=" + id +
                ", username='" + username + '\'' +
                ", password='" + password + '\'' +
                ", headImage='" + headImage + '\'' +
                ", lastLoginTime='" + lastLoginTime + '\'' +
                ", createTime='" + createTime + '\'' +
                ", email='" + email + '\'' +
                ", isReal='" + isReal + '\'' +
                ", nickname='" + nickname + '\'' +
                ", realUser=" + realUser +
                ", roleEntities=" + roleEntities +
                ", authorities=" + authorities +
                '}';
    }
}
